package com.dyz.leetcode._02_string;

public class _58_lengthOfLastWord {
    public int lengthOfLastWord(String s) {
        int start = s.length()-1;
        while (start>=0 && s.charAt(start)==' '){start--;}
        int end = start;
        while (end>=0 && s.charAt(end)!=' '){end--;}
        return start -end;
    }
}

